#pragma once

#include "EmpireLuaFunctions.h"

namespace Tmpl {

struct UnitData
{
	int flags;
	char name[16];
	char model[16];

	struct Unit
	{
		float hp;
		float speed;
		float size;
	};

	struct Building
	{
		float hp;
		char collisionFunc[32];
	};

	struct Projectile
	{
		float flightTime;
		float areaOfEffect;
		float dmg;
		float speed;
	};

	struct Doodadd
	{
		float hp;
		float size;
	};

	union 
	{
		Unit unit;
		Building building;
		Projectile projectile;
		Doodadd doodadd;
	};
};

class Empire
{
public:
	const char* GetRace(){return mRace;}

	UnitData GetUnitData(const char* unitName, int level);
	void ExecCollisionFunc(const char* func, int buildingId);
private:
	friend class EmpireSystem;

	char mRace[32];
	lua_State* mLuaState;
};

class EmpireSystem
{
public:
	static void Init();
	static void Clear();

	static int GetEmpireCount();
	static int NewEmpire(const char* race);
	static void RemoveEmpire(int id);
	static Empire* GetEmpire(int id);

	static JobHandle Update(JobHandle dependency);
private:
	static void UpdateEmpire(int empire);
};

}